package com.sanen.flyer.factory;

import com.sanen.flyer.entity.enemy.Enemy;
import com.sanen.flyer.entity.enemy.air1;
import com.sanen.flyer.tool.ImageTool;

import java.awt.image.BufferedImage;

/**
 * 敌机工厂
 * @author wsse
 * @date 2018-09-07 11:02
 */
public class EnemyFactory {
    public static final int HERO_HUAN_YING=1;
    public static BufferedImage air;

    public static Enemy getEnemy(int type){
        switch (type){
            case HERO_HUAN_YING:
                if (air==null)loadAir();
                return new air1(air, (int) (Math.random()*400),-100);
        }
        return null;
    }

    /**
     * 加载图片huanYing
     */
    private static synchronized void loadAir() {
        if (air==null)air= ImageTool.getImage("./image/aircraft/enemy/AIR01.png");
    }
}
